package cn.wolfcode.web.controller;


import cn.wolfcode.domain.Exam;
import cn.wolfcode.qo.ExamQueryObject;
import cn.wolfcode.qo.PageResult;
import cn.wolfcode.service.IExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/frontend/exam")
public class ExamController {

    @Autowired
    private IExamService examService;


    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") ExamQueryObject qo, Exam exam){
        //插入exam表
        Long examId = examService.save(exam);
        //插入中间表数据
        examService.save1(qo,examId);

        Exam exam1 = examService.selectByExam(examId);
        model.addAttribute("exam",exam1);
        PageResult show=examService.show(examId,qo);
        model.addAttribute("pageResult",show);
        return "exam/list";
    }

    @RequestMapping("/input")
    public String input(Exam exam) {
        return "exam/input";
    }
}
